<?php
require("dbFunctions.php");

/**
 * Given a requestor's email, update their first and last name.
 * Emails are unique, so these will not change and if they are
 * modifying this Requestor, it means they are already active.
 * 
 * Author: Steve Gennaoui
 * Date: 11/21/2012
 */

$requestor_email = $_REQUEST['email'];
$first_name = $_REQUEST['fname'];
$last_name = $_REQUEST['lname'];

if( is_null($requestor_email) )
	die("Requestor email was not provided.");
if( is_null($first_name) )
	die("First name was not provided.");
if( is_null($last_name) )
	die("Last name was not provided.");

$requestor_id = getIDByEmail($requestor_email,"Requestors");
if($requestor_id < 0)
	die("Invalid email provided.");

$dbh = connectDB();

$query = "UPDATE Requestors SET first_name=:fn,last_name=:ln,is_active=1 WHERE req_id=:id";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':fn',$first_name);
$stmt->bindParam(':ln',$last_name);
$stmt->bindParam(':id',$requestor_id);
$stmt->execute();

?>
